# Specify the project name and languages
project(o_txr_algo_dlm_v5 LANGUAGES CXX)

# Set compiler options for MSVC to use UTF-8 encoding
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

message("BOOST_ROOT: ${BOOST_ROOT}")
message("BOOST_INCLUDEDIR: ${BOOST_INCLUDEDIR}")
message("BOOST_LIBRARYDIR: ${BOOST_LIBRARYDIR}")

# Add include directories for libraries
include_directories(
    ${BOOST_INCLUDEDIR}
    ${MY_YAML_INCLUDE_DIR}
    ${MY_CRYPTOPP_INCLUDE_DIR}
    ${MY_OPENVINO_INCLUDE_DIR}
    ${MY_OPENCV_INCLUDE_DIR}
    # ${MY_IPP_INCLUDE_DIR}
)

# Specify library directories for linking
link_directories(
    ${MY_YAML_LIB_DIR}
    ${Boost_LIBRARY_DIRS}
    ${MY_CRYPTOPP_LIB_DIR}
    ${MY_OPENVINO_LIB_DIR}
    ${MY_OPENCV_LIBS_DIR}
    # ${MY_IPP_LIB_DIR}
)

# Set libraries to link against
set(O_TXR_ALGO_DLM_V5_LIBS
    ${MY_YAML_LIB}
    dxgi
    ${MY_CRYPTOPP_LIB}
    ${MY_OPENVINO_LIBS}
    ${MY_OPENCV_LIBS}
    ${MY_OPENCV_LIBS_DIR}/opencv_dnn.lib
    # ${MY_IPP_LIBS}
    Qt5::Core
    Qt5::Gui
    Qt5::Widgets
)

# Gather header and source files
file(GLOB_RECURSE CURRENT_HEADERS  *.h *.hpp *.cuh)
file(GLOB CURRENT_SOURCES  *.cpp *.cu)
source_group("Include" FILES ${CURRENT_HEADERS}) 
source_group("Source" FILES ${CURRENT_SOURCES}) 

# Create the shared library target
add_library(o_txr_algo_dlm_v5 SHARED
    ${CURRENT_HEADERS}
    ${CURRENT_SOURCES}
)

# Link the libraries to the shared library
target_link_libraries(o_txr_algo_dlm_v5 PRIVATE ${O_TXR_ALGO_DLM_V5_LIBS})

# Set environment variables for the executable
set(MY_PATH "PATH=%PATH%" 
    ${MY_CRYPTOPP_BIN_DIR} 
    ${MY_YAML_BIN_DIR} 
    ${MY_OPENVINO_BIN_DIR}
    ${MY_OPENCV_BIN_DIR}
    ${MY_IPP_BIN_DIR}
    ${Qt5_BIN_DIR})

# Set debugger environment for the executable
set_property(TARGET o_txr_algo_dlm_v5 PROPERTY VS_DEBUGGER_ENVIRONMENT ${MY_PATH})

# Install the shared library
install(TARGETS o_txr_algo_dlm_v5 DESTINATION lib)